function operatorView(){
	var operatorView = 
		"<html>"+
	"<head>"+
	"<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>"+
	"<title>Insert title here</title>"+
	"<script type='text/javascript' src='menu.js'></script>"+
	"</head>"+
	"<body><form name='clock' style='padding-left: 145px'>"+
	"<font face='DS-Digital' size='5px'><b>작업자"+
	" <input type='text' id='worker'value='' style='font-family: DS-Digital; font-size: 30px; border: none; width: 160px' readonly='readonly'> 일시 :"+
	" <input class='' type='text' id='date' style='font-family: DS-Digital; font-size: 30px; border: none; width: 180px' readonly='readonly'>"+
	" 현재시각 : <input type='text' id='time' style='font-family: DS-Digital; font-size: 30px; border: none' readonly='readonly'></b></font> </form>"+
	"<br><div id='menu'></div>"+
	"<div id='bri'></div>"+
	"<div id='oper_charts' style='width: 410px ; height: 300px; float:Left'>"+
	"<input type='hidden' id='month_goal_bad_number1' value=''><input type='hidden' id='day_goal_bad_number1' value=''><input type='hidden' id='month_goal_number1' value=''><input type='hidden' id='day_goal_number1' value=''><input type='hidden' id='month_success_number' value=''><input type='hidden' id='day_success_number' value=''><input type='hidden' id='month_bad_number' value=''><input type='hidden' id='day_bad_number' value=''>"+
	"<table>"+
	"	<tr><td>"+
	"	<table  width='410px' height='100'>"+
	"		<tr>"+
	"			<td colspan='2' bgcolor='black'><font color='white'>월별수불현황</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150' bgcolor='lightgrey'>목표불량</td><td width='150'><input type='text' id='month_goal_bad_number' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>불량수량</td><td><input type='text' id='month_production_bad_quantity' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table>"+
	"	</td><td>"+
	"	<table  width='820px' height='100'>"+
	"		<tr>"+
	"			<td colspan='4' bgcolor='black'><font color='white'>월별완성현황</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150' bgcolor='lightgrey'></td><td width='150'bgcolor='lightgrey'>목표</td><td width='150'bgcolor='lightgrey'>실적</td><td width='150'bgcolor='lightgrey'>진척률</td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>PLC</td><td><input type='text' id='month_goal_number' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='month_production_total_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='month_production_total_persent' value='' maxlength='5' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>LOT</td><td></td><td><input type='text' id='month_production_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='month_production_persent' value='' maxlength='5' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table>"+
	"	</td></tr>"+
	"	<tr><td>"+
	"	<table  width='410px' height='100'>"+
	"		<tr>"+
	"			<td colspan='2' bgcolor='black'><font color='white'>일별수불현황</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150' bgcolor='lightgrey'>목표불량</td><td width='150'><input type='text' id='day_goal_bad_number' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>불량수량</td><td><input type='text' id='day_production_bad_quantity' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table>"+
	"	</td><td>"+
	"	<table  width='820px' height='100'>"+
	"		<tr>"+
	"			<td colspan='4' bgcolor='black'><font color='white'>일별완성현황</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150' bgcolor='lightgrey'></td><td width='150' bgcolor='lightgrey'>목표</td><td width='150'bgcolor='lightgrey'>실적</td><td width='150'bgcolor='lightgrey'>진척률</td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>PLC</td><td><input type='text' id='day_goal_number' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='day_production_total_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='day_production_total_persent' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>LOT</td><td></td><td><input type='text' id='day_production_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='day_production_persent' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table> "+
	"   </td></tr> "+	
	"   <tr><td> "+
	"	<table width='410px' height='100'>"+
	"		<tr>"+
	"			<td colspan='4' bgcolor='black'><font color='white'>수불현황</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150'bgcolor='lightgrey'>목표불량</td><td width='150'><input type='text' id='workorder_badquantity' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>불량수량</td><td><input type='text' id='production_bad_quantity' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>불량률</td><td><input type='text' id='bad_persent' value='' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table>"+
	"   </td><td>"+
	"	<table width='820px' height='100'>"+
	"		<tr>"+
	"			<td colspan='4' bgcolor='black' width='400'><font color='white'>완성실적</font></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td width='150' bgcolor='lightgrey'></td><td width='150'bgcolor='lightgrey'>목표</td><td width='150'bgcolor='lightgrey'>실적</td><td width='150'bgcolor='lightgrey'>진척률</td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>PLC</td><td><input type='text' id='workorder_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='production_total_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='production_total_persent2' value='' maxlength='5' style='width:70px; border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"		<tr>"+
	"			<td bgcolor='lightgrey'>LOT</td><td></td><td><input type='text' id='production_quantity' value='' style='width:70px;border: none' readonly='readonly'></td><td><input type='text' id='production_persent2' value='' maxlength='5' style='width:70px;border: none' readonly='readonly'></td>"+
	"		</tr>"+
	"	</table>"+
	"   </td></tr>"+
	"</table> "+
	"</div>"+
	"<div id='oper_charts2' style='width: 410px ; height: 300px; float:Left'></div>"+
	"<div id='oper_charts3' style='width: 410px ; height: 300px; float:Left'></div>"+
	"<input type='hidden' id='state' value=''>"+
	"</body>"+
	"</html>";
	$("#main").html(operatorView);
	$("#menu").html(menuBar());
	production_operator();
	clock();
	worker();
	$.ajax({
		type : "POST",
		url : "login.do",
		data : "command=workorderCheck",
		dataType : "json",
		success : function(jsonData){
			var workorder_quantity=0;
			workorder_quantity= parseInt(jsonData.wvo.workorder_quantity);
			var workorder_badquantity=0;
			workorder_badquantity= parseInt(jsonData.wvo.workorder_badquantity);
			$("#workorder_quantity").val(parseInt(workorder_quantity));
			$("#workorder_badquantity").val(parseInt(workorder_badquantity));
		}
	});
	$.ajax({
		type : "POST",
		url : "operator.do",
		data : "command=operatorResultView",
		dataType : "json",
		success : function(jsonData){
			var workorder_quantity=0;
			workorder_quantity= $("#workorder_quantity").val();
			var workorder_badquantity=0;
			workorder_badquantity= $("#workorder_badquantity").val();
			var month_goal_number=0;
			month_goal_number= parseInt(workorder_quantity)+parseInt(jsonData.result_map.month_goal_number);
			var day_goal_number=0;
			day_goal_number=parseInt(workorder_quantity)+parseInt(jsonData.result_map.day_goal_number);
			var month_goal_bad_number=0;
			month_goal_bad_number= parseInt(workorder_badquantity)+parseInt(jsonData.result_map.month_goal_bad_number);
			var day_goal_bad_number=0;
			day_goal_bad_number= parseInt(workorder_badquantity)+parseInt(jsonData.result_map.day_goal_bad_number);
			$("#month_goal_number1").val(parseInt(jsonData.result_map.month_goal_number));
			$("#day_goal_number1").val(parseInt(jsonData.result_map.day_goal_number));
			$("#month_goal_number").val(parseInt(month_goal_number));
			$("#day_goal_number").val(parseInt(day_goal_number));
			$("#month_goal_bad_number").val(parseInt(month_goal_bad_number));
			$("#day_goal_bad_number").val(parseInt(day_goal_bad_number));
			$("#month_goal_bad_number1").val(parseInt(jsonData.result_map.month_goal_bad_number));
			$("#day_goal_bad_number1").val(parseInt(jsonData.result_map.day_goal_bad_number));
			var month_success_number=0;
			month_success_number=parseInt(jsonData.result_map.month_success_number)+parseInt(jsonData.result_map.month_bad_number);
			$("#month_success_number").val(month_success_number);
			var day_success_number=0;
			day_success_number=parseInt(jsonData.result_map.day_success_number)+parseInt(jsonData.result_map.day_bad_number);
			$("#day_success_number").val(day_success_number);
			$("#month_bad_number").val(parseInt(jsonData.result_map.month_bad_number));
			$("#day_bad_number").val(parseInt(jsonData.result_map.day_bad_number));
		}
	});
}

function clock(){
	 data = new Date();
	 // 시간과 관련된 정보를 저장한다.
	 hours = data.getHours();
	 minutes = data.getMinutes();
	 seconds = data.getSeconds();
	 timeStr = hours;
	 timeStr += ((minutes < 10) ? ":0" : ":") + minutes;
	 timeStr += ((seconds < 10) ? ":0" : ":") + seconds;
	 // 폼의 시간을 표시하는 입력란에 문자열을 출력한다.
	 document.clock.time.value = timeStr;
	 // 일자와 관련된 정보를 저장한다.
	 months = data.getMonth() + 1;
	 days = data.getDate();
	 years = 2012+"/";
	 dateStr = ((years < 10) ? "/0" : "") + years;
	 dateStr += months+"/";
	 dateStr += ((days < 10) ? "/0" : "") + days;
	 // 폼의 일자를 표시하는 입력란에 문자열을 출력한다.
	 document.clock.date.value = dateStr;
	 // 1초마다 일자와 시간을 갱신한다.
	 Timer = setTimeout("clock()", 1000);
}

function worker(){
	document.clock.worker.value='Operator';
}

function production_operator(){
	$.ajax({
		type : "POST",
		url : "operator.do",
		data : "command=production_view",
		dataType : "json", 
		success : function(jsonData) {
			var production_quantity=0;
			production_quantity= parseInt(jsonData.production_map.production_quantity);
			var production_bad_quantity1=0;
			production_bad_quantity1= parseInt(jsonData.production_map.production_bad_quantity1)+parseInt(jsonData.production_map.production_bad_quantity11);
			var production_bad_quantity2=0;
			production_bad_quantity2= parseInt(jsonData.production_map.production_bad_quantity2)+parseInt(jsonData.production_map.production_bad_quantity22);
			var production_bad_quantity11=0;
			production_bad_quantity11= parseInt(jsonData.production_map.production_bad_quantity11);
			var production_bad_quantity22=0;
			production_bad_quantity22= parseInt(jsonData.production_map.production_bad_quantity22);
			var production_bad_quantity3=0;
			production_bad_quantity3= parseInt(jsonData.production_map.production_bad_quantity3);
			var production_bad_quantity4=0;
			production_bad_quantity4= parseInt(jsonData.production_map.production_bad_quantity4);
			var production_bad_quantity=0;
			production_bad_quantity= parseInt(production_bad_quantity1+production_bad_quantity2+production_bad_quantity3+production_bad_quantity4);
			var production_total_quantity=0;
			//현재 공정 실적 PCL 수정 하는 부분 재가공만 +되있던거 전부 +로 바꿈
			production_total_quantity= parseInt(production_quantity+production_bad_quantity1+production_bad_quantity2+production_bad_quantity3+production_bad_quantity4);
			var production_state = jsonData.production_map.production_state;
			$("#state").val(production_state);
			
			var workorder_quantity=0;
			workorder_quantity= $("#workorder_quantity").val();
			var production_total_persent=0;
			production_total_persent= ((parseInt(production_total_quantity)/parseInt(workorder_quantity))*100).toFixed(1)+'%';
			var production_persent=0;
			production_persent= ((parseInt(production_quantity)/parseInt(workorder_quantity))*100).toFixed(1)+'%';
			$("#production_quantity").val(parseInt(production_quantity));
			$("#production_bad_quantity").val(parseInt(production_bad_quantity));
			$("#production_total_quantity").val(parseInt(production_total_quantity));
			$("#production_total_persent").val(production_total_persent);
			$("#production_persent").val(production_persent);
			$("#production_total_persent2").val(production_total_persent);
			$("#production_persent2").val(production_persent);
			workorder_badquantity= $("#workorder_badquantity").val();
			$("#bad_persent").val(((production_bad_quantity/workorder_badquantity)*100).toFixed(1)+'%');
			
			var month_goal_number1=0;
			month_goal_number1= $("#month_goal_number1").val();
			var day_goal_number1=0;
			day_goal_number1= $("#day_goal_number1").val();
			var month_goal_bad_number1=0;
			month_goal_bad_number1= $("#month_goal_bad_number1").val();
			var day_goal_bad_number1=0;
			day_goal_bad_number1= $("#day_goal_bad_number1").val();
			var month_goal_number=0;
			month_goal_number= $("#month_goal_number").val();
			var day_goal_number=0;
			day_goal_number= $("#day_goal_number").val();
			var month_goal_bad_number=0;
			month_goal_bad_number= $("#month_goal_bad_number").val();
			var day_goal_bad_number=0;
			day_goal_bad_number= $("#day_goal_bad_number").val();
			
			
			//LOT percent
			var day_production_persent = (((parseInt(day_goal_number1)+
					parseInt(production_quantity))/parseInt(day_goal_number))*100).toFixed(1)+"%";
			//일별 숫자를 넣는 곳==============================================================
			//생산 성공 수량(PLC)
			$("#day_production_quantity").val(parseInt(day_goal_number1)+
					parseInt(production_quantity));
			//실패 수량(수불현황)
			var day_bad_number =0;
			day_bad_number=$("#day_bad_number").val();
			//오늘 불량이랑 지금 불량 합치는거
			var day_production_bad_quantity = 0;
			day_production_bad_quantity = parseInt(day_bad_number)+	parseInt(production_bad_quantity)
			$("#day_production_bad_quantity").val(day_production_bad_quantity);
			//생산과 재가공 +SUM+ (LOT)
			var day_success_number1=0;
			day_success_number1=$("#day_success_number").val();
			var day_production_total_quantity=0;
			//최신 목표 뺴고 현재 생산 +하는거 + 불량
//			day_production_total_quantity=parseInt(day_success_number1)+parseInt(day_production_bad_quantity);
			day_production_total_quantity=parseInt(day_goal_number1)+parseInt(production_total_quantity)+parseInt(day_production_bad_quantity);
			//오늘 오류량과 + 오늘 생산량 합치는거
			$("#day_production_total_quantity").val(day_production_total_quantity);
			//PLC percent
			//위치수정 안에 토탈갯수 일일이 쓰던거 한번에 수정
			var day_production_total_persent = (day_production_total_quantity/parseInt(day_goal_number)*100).toFixed(1)+"%";
			$("#day_production_total_persent").val(day_production_total_persent);
			//LOT percent
			$("#day_production_persent").val(day_production_persent);
			

			var month_production_persent=0;
			month_production_persent= (((parseInt(month_goal_number1)+parseInt(production_quantity))/parseInt(month_goal_number))*100).toFixed(1)+"%";
			$("#month_production_quantity").val(parseInt(month_goal_number1)+parseInt(production_quantity));

			//실패 수량(수불현황)
			var month_bad_number =0;
			month_bad_number=$("#month_bad_number").val();
			//월별 불량 생산
			//월 불량이랑 지금 불량 합치는거
			var month_production_bad_quantity = 0;
			month_production_bad_quantity = parseInt(month_bad_number)+parseInt(production_bad_quantity)
			$("#month_production_bad_quantity").val(month_production_bad_quantity);
			var month_success_number1=0;
			month_success_number1=$("#month_success_number").val();
			var month_production_total_quantity=0;
//			month_production_total_quantity=parseInt(month_success_number1)+parseInt(production_total_quantity)
			//최신 목표 뺴고 현재 생산 +하는거 + 불량
			month_production_total_quantity=parseInt(month_goal_number1)+parseInt(production_total_quantity)+parseInt(month_production_bad_quantity);
			$("#month_production_total_quantity").val(month_production_total_quantity);
			//위치수정 안에 토탈갯수 일일이 쓰던거 한번에 수정
			var month_production_total_persent=0;
			month_production_total_persent= (parseInt(month_production_total_quantity)/parseInt(month_goal_number)*100).toFixed(1)+"%";
			$("#month_production_total_persent").val(month_production_total_persent);
			$("#month_production_persent").val(month_production_persent);
			
			if(production_state=='start'){
				$("#footer").html("<img src='img/start.gif'>");
			}else{
				$("#footer").html("<img src='img/stop.gif'>");
			}
			production_operator();
		}
	});
}

function ord(){
	$("#bri").html("<div id='order_form'></div>");
	$("#order_form").html(function(){
		var state = $("#state").val();
		var form="";
		if(state=="stop"){
		form="생산지시";
		form+="<table><tr>";
		form+="<td><input type='text' id='to_workorder_quantity' placeholder='생산수량' style='width:70px;'><br>";
		form+="<input type='text' id='to_workorder_bad' placeholder='목표불량' style='width:70px;'></td>";
		form+="<td rowspan='2'><input type='button' id='order' style='height: 50px; width: 70px' value='지시'></input></td>";	
		form+="</tr></table>";
		}else{
			alert("공정중에는 생산지시를 내릴수 없습니다.")
		}
		return form;
	});
};
$(function(){
	$("#main").on("click","#order",function(){
		var to_workorder_quantity = $("#to_workorder_quantity").val();
		var to_workorder_bad = $("#to_workorder_bad").val();
		if(to_workorder_quantity==""){
			alert("목표 갯수를 지정해주세요");
			return false;
		}
		if(to_workorder_bad==""){
			alert("불량목표 갯수를 지정해주세요");
			return false;
		}
		var flag="insert";
		var production_quantity = $("#production_quantity").val();
		if(production_quantity==0){
			flag="update";
			var workorder_quantity = $("#workorder_quantity").val();
			if(workorder_quantity==0){				
				flag="insert";
			}
		}
		$.ajax({
			type : "POST",
			url : "operator.do",
			data : "command=workOrderInsert&workorder_quantity="+to_workorder_quantity+"&workorder_bad="+to_workorder_bad+"&flag="+flag,
		});
		$.ajax({
			type : "POST",
			url : "operator.do",
			data : "command=operatorResultView",
			dataType : "json",
			success : function(jsonData){
				var workorder_quantity=0;
				workorder_quantity= $("#workorder_quantity").val();
				var workorder_badquantity=0;
				workorder_badquantity= $("#workorder_badquantity").val();
				var month_goal_number=0;
				month_goal_number= parseInt(workorder_quantity)+parseInt(jsonData.result_map.month_goal_number);
				var day_goal_number=0;
				day_goal_number=parseInt(workorder_quantity)+parseInt(jsonData.result_map.day_goal_number);
				var month_goal_bad_number=0;
				month_goal_bad_number= parseInt(workorder_badquantity)+parseInt(jsonData.result_map.month_goal_bad_number);
				var day_goal_bad_number=0;
				day_goal_bad_number= parseInt(workorder_badquantity)+parseInt(jsonData.result_map.day_goal_bad_number);
				$("#month_goal_number1").val(parseInt(jsonData.result_map.month_goal_number));
				$("#day_goal_number1").val(parseInt(jsonData.result_map.day_goal_number));
				$("#month_goal_number").val(parseInt(month_goal_number));
				$("#day_goal_number").val(parseInt(day_goal_number));
				$("#month_goal_bad_number").val(parseInt(month_goal_bad_number));
				$("#day_goal_bad_number").val(parseInt(day_goal_bad_number));
				$("#month_goal_bad_number1").val(parseInt(jsonData.result_map.month_goal_bad_number));
				$("#day_goal_bad_number1").val(parseInt(jsonData.result_map.day_goal_bad_number));
				$("#month_success_number").val(parseInt(jsonData.result_map.month_success_number)+parseInt(jsonData.result_map.month_bad_number));
				$("#day_success_number").val(parseInt(jsonData.result_map.day_success_number)+parseInt(jsonData.result_map.day_bad_number));
				$("#month_bad_number").val(parseInt(jsonData.result_map.month_bad_number));
				$("#day_bad_number").val(parseInt(jsonData.result_map.day_bad_number));
			}
		});
		var month_goal_number1 = $("#month_goal_number1").val();
		var day_goal_number1 = $("#day_goal_number1").val();
		var month_goal_bad_number1 = $("#month_goal_bad_number1").val();
		var day_goal_bad_number1 = $("#day_goal_bad_number1").val();
		
		$("#month_bad_number").val(month_goal_bad_number1);
		$("#day_bad_number").val(day_goal_bad_number1);
		
		$("#workorder_quantity").val(to_workorder_quantity);
		$("#workorder_badquantity").val(to_workorder_bad);
		$("#month_goal_number").val(parseInt(to_workorder_quantity)+parseInt(month_goal_number1));
		$("#day_goal_number").val(parseInt(to_workorder_quantity)+parseInt(day_goal_number1));
		$("#month_goal_bad_number").val(parseInt(to_workorder_bad)+parseInt(month_goal_bad_number1));
		$("#day_goal_bad_number").val(parseInt(to_workorder_bad)+parseInt(day_goal_bad_number1));
		
		$("#order_form").html(function(){
			
		});		
	});	
});